# Use C-a instead of C-b as the prefix
set -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

#set 256 colors
set -g default-terminal "screen-256color"

# set default shell
set -g default-command "exec /bin/zsh"

set -g display-time 2000

# set vi style key binding
set -g status-keys vi
setw -g mode-keys vi

# be more responsive, changing the default delay
set -sg escape-time 1

# set scrollback
set -g history-limit 10000

# Start numbering at 1
set -g base-index 1
setw -g pane-base-index 1

# force a reload of the config file
unbind =
bind = source-file ~/.tmux.conf  \; display "Reloaded!"

# automatic window renaming
set-window-option -g automatic-rename on

# aggresive resize
setw -g aggressive-resize on

# Saner splitting.
bind , split-window -h
bind . split-window -v
bind S choose-session

# Pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# set colors
set -g status-bg colour234
set -g window-status-activity-attr bold
set -g pane-border-fg colour245
set -g pane-active-border-fg colour39
set -g message-fg colour16
set -g message-bg colour221
set -g message-attr bold

# Custom status bar
# Status bar
set -g status-position bottom
set -g status-interval 4
set -g status-left ''
set -g status-right ''
set -g status-justify centre # center align window list

setw -g status-bg default
setw -g window-status-current-bg default
setw -g window-status-current-fg default
setw -g window-status-bg default
setw -g window-status-fg white
setw -g window-status-format '#[bg=black]#[fg=black,bold] #I #[bg=default] #[fg=black]#W  '
setw -g window-status-current-format '#[fg=white]#[bg=cyan] #I #[fg=cyan]#[bg=default] #W  '

# Panel borders
set -g pane-active-border-fg cyan
set -g pane-active-border-bg default
set -g pane-border-fg black
set -g pane-border-bg default

# Activity
setw -g monitor-activity on
set -g visual-activity on

# Mouse stuff
setw -g mouse off

# Log output to a text file on demand
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"

# move between panes
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
